echo 'namespace SimpleServer;' > BuildDate.cs
echo 'public partial interface ICom' >> BuildDate.cs
echo '{' >> BuildDate.cs
echo -e "\tpublic static string BuiltWhen=\"$(date "+%Y-%m-%d %H:%M:%S")\";" >> BuildDate.cs
echo '}' >> BuildDate.cs

rm -rf {bin,obj,linux,windows}
dotnet publish -o linux -a x64 -c Release --sc -p:PublishSingleFile=true -p:PublishTrimmed=true
dotnet publish -o windows --os win -c Release --sc -p:PublishSingleFile=true -p:PublishTrimmed=true
rm -rf {bin,obj}

path=`pwd`
dir=`pwd | rev | cut -d "/" -f 1 | rev`
echo '#!/usr/bin/env xdg-open' > a.desktop
echo '[Desktop Entry]' >> a.desktop
echo "Name=$dir" >> a.desktop
echo 'Terminal=true' >> a.desktop
echo 'Type=Application' >> a.desktop
echo "Icon = /home/$USER/ico/corn3_00001.ico" >> a.desktop
echo "Exec=$path/linux/$dir" >> a.desktop
echo "Path = $path" >> a.desktop

rm -f server
ln -s "$path/linux/$dir" server